*==================**# SET UP*==================* LOAD PACAKAGES AND DATA	set matsize 3000	ssc install ivreg2,replace	ssc install ranktest,replace	ssc install outreg2	ssc install reghdfe	ssc install mdesc	ssc install weakivtest	ssc install avar			use income.dta,clear 		 		 		 *=======================**# TABLE 1*=======================		use income.dta,clear	table year,c(sum Car_N) format(%20.0gc)	* city macro	tabstat Car_N Car_RMB Car_wPrice income builtup pavedroad pop taxi bus retail o4_empedu hightech,stat(mean sd cv min max p50 n) columns(statistics) format(%10.0gc)	* city macro five groups	tabstat Car_N Car_RMB Car_wPrice income builtup pavedroad pop taxi bus retail o4_empedu hightech,stat(mean sd n)  format(%10.0gc) by(q_2005)			*=======================**# TABLE 3*=======================		use income.dta,clear	* COLUMN 1: OLS Log new registrations 	qui areg ln_saleN ln_pop ln_income i.prov_yr ,absorb(cityid) cluster(cityid)	outreg2 using regtable1.xls,	stats(coef se) noaster dec(2) ctitle("Log new registrations")  keep(ln_income)   nocons replace	* COLUMN 2: IV 	Log new registrations	qui ivreg2 ln_saleN ln_pop   i.cityid i.prov_yr (ln_income= IV_lnhightechedu) , partial(i.cityid  i.prov_yr) cluster (cityid) first savefirst	estimates replay _ivreg2_ln_income	mat FS= r(table)	scalar FS_b=round(FS[1,1],0.01)	scalar FS_se=round(FS[2,1],0.01)	scalar FS_p=FS[4,1]	outreg2 using regtable1.xls,stats(coef se) noaster dec(2) ctitle("Log new registrations") addstat(F for IV,  e(rkf),underid(Kleibergen-Paap rk LM), e(idstat), underid_pval, e(idp),First stage beta,FS_b,se,FS_se) nocons keep(ln_income)	* Effective F stat	ivreg2 ln_saleN ln_pop   i.cityid i.prov_yr (ln_income= IV_lnhightechedu) , partial(i.cityid  i.prov_yr) cluster (cityid) first savefirst	* COLUMN 3: First stage from column 2 		* COLUMN 4: IV Log new expenditure	qui ivreg2 ln_saleRMB ln_pop   i.cityid i.prov_yr (ln_income= IV_lnhightechedu) , partial(i.cityid  i.prov_yr) cluster (cityid) first savefirst	estimates replay _ivreg2_ln_income	mat FS= r(table)	scalar FS_b=round(FS[1,1],0.01)	scalar FS_se=round(FS[2,1],0.01)	scalar FS_p=FS[4,1]	outreg2 using regtable1.xls,stats(coef se) noaster dec(2) ctitle("Log new revenue") addstat(F for IV,  e(rkf),underid(Kleibergen-Paap rk LM), e(idstat), underid_pval, e(idp),First stage beta,FS_b,se,FS_se) nocons keep(ln_income)	* COLUMN 5: IV Log average price 	qui ivreg2 ln_salePrice ln_pop   i.cityid i.prov_yr (ln_income= IV_lnhightechedu) , partial(i.cityid  i.prov_yr) cluster (cityid) first  savefirst 	estimates replay _ivreg2_ln_income	mat FS= r(table)	scalar FS_b=round(FS[1,1],0.01)	scalar FS_se=round(FS[2,1],0.01)	scalar FS_p=FS[4,1]	outreg2 using regtable1.xls,stats(coef se) noaster dec(2) ctitle("Log average price") addstat(F for IV,  e(rkf),underid(Kleibergen-Paap rk LM), e(idstat), underid_pval, e(idp),First stage beta,FS_b,se,FS_se) nocons keep(ln_income)	*  Footnote: drop 2017	drop if year==2017	qui ivreg2 ln_saleN ln_pop   i.cityid i.prov_yr (ln_income= IV_lnhightechedu), partial(i.cityid  i.prov_yr) cluster (cityid) first savefirst	estimates replay _ivreg2_ln_income	mat FS= r(table)	scalar FS_b=round(FS[1,1],0.01)	scalar FS_se=round(FS[2,1],0.01)	scalar FS_p=FS[4,1]	outreg2 using regtable1_drop2017.xls,stats(coef se) noaster dec(2) ctitle("Log new registrations") addstat(F for IV,  e(rkf),underid(Kleibergen-Paap rk LM), e(idstat), underid_pval, e(idp),First stage beta,FS_b,se,FS_se) nocons keep(ln_income)			*=======================**# TABLE 4*=======================		use income.dta,clear		global ln_X ln_builtup ln_pavedroad  ln_taxi ln_bus ln_retail 	* COLUMN 1: IV Log new registrations with year fixed effects, without controls		qui ivreg2 ln_saleN ln_pop   i.cityid i.year (ln_income= IV_lnhightechedu) , partial(i.cityid  i.year) cluster (cityid) first savefirst	estimates replay _ivreg2_ln_income	mat FS= r(table)	scalar FS_b=round(FS[1,1],0.01)	scalar FS_se=round(FS[2,1],0.01)	scalar FS_p=FS[4,1]	di FS_b	di FS_se	outreg2 using regtable2.xls,stats(coef se) noaster dec(2) ctitle("Log new registrations")  addtext(Province by year FE,NO, Socio-economic controls, NO, Avg quantile income in 2005 by year tend, NO) addstat(F for IV,  e(rkf),underid(Kleibergen-Paap rk LM), e(idstat), underid_pval, e(idp),First stage beta,FS_b,se,FS_se) nocons keep(ln_income)			*Effective F stats	ivreg2 ln_saleN ln_pop   i.cityid i.year (ln_income= IV_lnhightechedu) ,  cluster (cityid) first savefirst	weakivtest		* COLUMN 2: IV Log new registrations without controls (main)		qui ivreg2 ln_saleN ln_pop   i.cityid i.prov_yr (ln_income= IV_lnhightechedu) , partial(i.cityid  i.prov_yr) cluster (cityid) first savefirst	estimates replay _ivreg2_ln_income	mat FS= r(table)	scalar FS_b=round(FS[1,1],0.01)	scalar FS_se=round(FS[2,1],0.01)	scalar FS_p=FS[4,1]	di FS_b	di FS_se	outreg2 using regtable2.xls,stats(coef se) noaster dec(2) ctitle("Log new registrations") addtext(Province by year FE,YES, Socio-economic controls, NO, Avg quantile income in 2005 by year tend, NO) addstat(F for IV,  e(rkf),underid(Kleibergen-Paap rk LM), e(idstat), underid_pval, e(idp),First stage beta,FS_b,se,FS_se) nocons keep(ln_income)	* COLUMN 3: IV 	IV Log new registrations with province by year quadratic trend 	gen cyear = year - 2010 //center	encode prov,gen(provid)	ivreg2 ln_saleN ln_pop   i.cityid i.prov_yr (ln_income= IV_lnhightechedu) i.provid##c.cyear##c.cyear , partial(i.cityid) cluster (cityid) first savefirst	estimates replay _ivreg2_ln_income	mat FS= r(table)	scalar FS_b=round(FS[1,1],0.01)	scalar FS_se=round(FS[2,1],0.01)	scalar FS_p=FS[4,1]	di FS_b 	di FS_se 	di e(rkf) 	di e(idstat) 	di e(idp) 		* COLUMN 4:  IV Log new registrations with socio-economic variables	global ln_X ln_builtup ln_pavedroad  ln_taxi ln_bus ln_retail 	qui ivreg2 ln_saleN ln_pop $ln_X  i.cityid i.prov_yr (ln_income= IV_lnhightechedu) , partial(i.cityid  i.prov_yr) cluster (cityid) first savefirst	estimates replay _ivreg2_ln_income	mat FS= r(table)	scalar FS_b=round(FS[1,1],0.01)	scalar FS_se=round(FS[2,1],0.01)	scalar FS_p=FS[4,1]	di FS_b	di FS_se	outreg2 using regtable2.xls,stats(coef se) noaster dec(2) ctitle("Log new registrations")  addtext(Province by year FE,YES, Socio-economic controls, YES, Avg quantile income in 2005 by year tend, NO) addstat(F for IV,  e(rkf),underid(Kleibergen-Paap rk LM), e(idstat), underid_pval, e(idp),First stage beta,FS_b,se,FS_se) nocons keep(ln_income)			*Effective F stats	ivreg2 ln_saleN ln_pop $ln_X  i.cityid i.prov_yr (ln_income= IV_lnhightechedu) , cluster (cityid) first savefirst	weakivtest// 78.85		*=======================**# TABLE 5*=======================		use income.dta,clear	* COLUMN 1: Repeat column 2 of Table 3* COLUMN 2: Alternative IV	use 2004_3ins.dta,clear	merge m:1 ins using 04-17_ins.dta	sort  市	drop _merge	capture drop w_*	foreach var in yr2004 yr2005 yr2006 yr2007 yr2008 yr2009 yr2010 yr2011 yr2012 yr2013 yr2014 yr2015 yr2016 yr2017 yr2018 yr2019 yr2020 {		gen w_`var'=weight*`var'		bysort 市: egen wsum_`var'=total(w_`var')			}	bysort 市: gen keepit=_n	keep if keepit==1	keep 市 wsum*	reshape long wsum_yr,i(市) j(year) 	rename wsum_yr IV_3ins	rename 市 city	save 2-IV_3ins.dta,replace	use income.dta		merge 1:1 year city using 2-IV_3ins.dta	drop if _merge==2	drop _merge	gen IV_ln3inds=log(IV_3ins)		* Regression	qui ivreg2 ln_saleN ln_pop   i.cityid i.prov_yr (ln_income= IV_ln3inds) , partial(i.cityid  i.prov_yr) cluster (cityid) first savefirst	estimates replay _ivreg2_ln_income	mat FS= r(table)	scalar FS_b=round(FS[1,1],0.01)	scalar FS_se=round(FS[2,1],0.01)	scalar FS_p=FS[4,1]	outreg2 using temp,stats(coef se) noaster dec(2) ctitle("Log new registrations") addstat(F for IV,  e(rkf),underid(Kleibergen-Paap rk LM), e(idstat), underid_pval, e(idp),First stage beta,FS_b,se,FS_se) nocons keep(ln_income) dta 	* Effective F stat	ivreg2 ln_saleN ln_pop   i.cityid i.prov_yr (ln_income= IV_ln3inds) , partial(i.cityid  i.prov_yr) cluster (cityid) first savefirst	* COLUMN 3: Log income * post 2010	gen post=0	replace post=1 if year>2010	gen ipost = ln_income * post	gen IVpost = IV_lnhightechedu * post		qui ivreg2 ln_saleN ln_pop   i.cityid  i.prov_yr (ln_income ipost = IV_lnhightechedu IVpost ) , partial(i.cityid  i.prov_yr) cluster (cityid) first 	outreg2 using  regtable1.xls  ,stats(coef se) noaster dec(2) ctitle("Log new registrations") addstat(F for IV,  e(rkf),underid(Kleibergen-Paap rk LM), e(idstat), underid_pval, e(idp)) nocons keep(ln_income ipost)		* COLUMN 3': Log income * post 2010 and city by post FE suggested by referee	gen post=0	replace post=1 if year>2010	gen ipost = ln_income * post	gen IVpost = IV_lnhightechedu * post	egen citypost=group(city post)	ivreg2 ln_saleN ln_pop   i.cityid  i.prov_yr i.citypost (ln_income ipost = IV_lnhightechedu IVpost ) , partial(i.cityid  i.prov_yr i.citypost) cluster (cityid) first 	test ipost=0		estimates replay _ivreg2_ln_income	mat FS= r(table)	scalar FS_b=round(FS[1,1],0.01)	scalar FS_se=round(FS[2,1],0.01)	scalar FS_p=FS[4,1]	di e(rkf)	di e(idstat)	di e(idp)	outreg2 using  regtable1.xls  ,stats(coef se) noaster dec(2) ctitle("Log new registrations") addstat(F for IV,  e(rkf),underid(Kleibergen-Paap rk LM), e(idstat), underid_pval, e(idp)) nocons keep(ln_income ipost)		*  COLUMN 4: license plate cap		* generate dummy for cities that has license plate cap in place at the time	gen cap=0	replace cap=1	if 	prov=="上海"	&	year>=	1994	replace cap=1	if 	prov=="北京"	&	year>=	2011	replace cap=1	if 	city=="贵阳市"	&	year>=	2011	replace cap=1	if 	city=="广州市"	&	year>=	2014	replace cap=1	if 	prov=="天津"	&	year>=	2014    replace cap=1	if 	city=="杭州市"	&	year>=	2014	replace cap=1	if 	city=="深圳市"	&	year>=	2015		* second reg, interact cap city with log income 	gen icap = ln_income * cap	gen IVcap = IV_lnhightechedu * cap		qui ivreg2 ln_saleN ln_pop   i.cityid  i.prov_yr (ln_income icap = IV_lnhightechedu IVcap ) , partial(i.cityid  i.prov_yr) cluster (cityid) first 	outreg2 using regtable2.xls,stats(coef se) noaster dec(2) ctitle("Log new registrations")  addtext(Province by year FE,YES, Socio-economic controls, NO, Avg quantile income in 2005 by year tend, NO) addstat(F for IV,  e(rkf),underid(Kleibergen-Paap rk LM), e(idstat), underid_pval, e(idp)) nocons keep(ln_income icap)			* graph income as sale at 2005 level, normalize cap year ==0	keep if inlist(city, "北京市","上海市","贵阳市","广州市","天津市","杭州市","深圳市") 	gen t=.	replace t=year-2005 if 	prov=="上海"	replace t=year-2011 if 	prov=="北京"	replace t=year-2011 if 	city=="贵阳市"	replace t=year-2014 if 	city=="广州市"	replace t=year-2014 if 	prov=="天津"	replace t=year-2014 if 	city=="杭州市"	replace t=year-2015 if 	city=="深圳市"	gen Car_N2005 = Car_N if year==2005	bysort city: egen Car_N2005max=max(Car_N2005)	drop Car_N2005	rename Car_N2005max Car_N2005	gen Car_N_normalized = Car_N/Car_N2005		gen income2005 = income if year==2005	bysort city: egen income2005max=max(income2005)	drop income2005	rename income2005max income2005	gen income_normalized = income/income2005		separate Car_N_normalized ,by(city)	twoway line Car_N_normalized1- Car_N_normalized6 t, legend(label (1 "Shanghai") label(2 "Beijing") label(3 "Guiyang")  label(4 "Guangzhou")  label(5 "Tianjin")  label(6 "Hangzhou")  label(7 "Shenzhen"))  ytitle("Vehicle sales (index normalized to 2005 as 1)") xtitle("Cap policy implementation") lcolor(%90 %90 %50 %90 %80 %50 %50) 	//title("Vehicle sale growth rate trend")	* COLUMN 5: time trend with 2005 average income for the city's income quintile 		qui ivreg2 ln_saleN ln_pop   i.cityid i.prov_yr  c.avg_income_2005#i.year  (ln_income= IV_lnhightechedu) , partial(i.cityid  i.prov_yr) cluster (cityid) first savefirst	estimates replay _ivreg2_ln_income	mat FS= r(table)	scalar FS_b=round(FS[1,1],0.01)	scalar FS_se=round(FS[2,1],0.01)	scalar FS_p=FS[4,1]	di FS_b	di FS_se	outreg2 using regtable2.xls,stats(coef se) noaster dec(2) ctitle("Log new registrations")  addtext(Province by year FE,YES, Socio-economic controls, NO, Avg quantile income in 2005 by year tend, YES) addstat(F for IV,  e(rkf),underid(Kleibergen-Paap rk LM), e(idstat), underid_pval, e(idp),First stage beta,FS_b,se,FS_se) nocons keep(ln_income)			*Effective F stats	ivreg2 ln_saleN ln_pop   i.cityid i.prov_yr  c.avg_income_2005#i.year  (ln_income= IV_lnhightechedu) ,  cluster (cityid) first savefirst	weakivtest 		*=======================**# TABLE 6*=======================		use income.dta,clear* lag of income(-1,-2,-3)	sort cityid year	bysort cityid: gen ln_income_l1=ln_income[_n-1]	bysort cityid: gen ln_income_l2=ln_income[_n-2]	bysort cityid: gen ln_income_l3=ln_income[_n-3]		bysort cityid: gen IV_l1=IV_lnhightechedu[_n-1]	bysort cityid: gen IV_l2=IV_lnhightechedu[_n-2]	bysort cityid: gen IV_l3=IV_lnhightechedu[_n-3]			* COLUMN 1  = repleat TABLE 3 COLUMN 2* COLUMN 2 lag1		qui ivreg2 ln_saleN ln_pop   i.cityid i.prov_yr (ln_income_l1= IV_l1) , partial(i.cityid  i.prov_yr) cluster (cityid) first savefirst	estimates replay _ivreg2_ln_income_l1	mat FS= r(table)	scalar FS_b=round(FS[1,1],0.01)	scalar FS_se=round(FS[2,1],0.01)	scalar FS_p=FS[4,1]	outreg2 using regtable3.xls,stats(coef se) noaster dec(2) ctitle("Log new registrations") addstat(F for IV,  e(rkf),underid(Kleibergen-Paap rk LM), e(idstat), underid_pval, e(idp),First stage beta,FS_b,se,FS_se) nocons keep(ln_income_l1)					* Effective F stat	ivreg2 ln_saleN ln_pop   i.cityid i.prov_yr (ln_income_l1= IV_l1) ,  cluster (cityid) first savefirst	weakivtest				* COLUMN 3 lag2		qui ivreg2 ln_saleN ln_pop   i.cityid i.prov_yr (ln_income_l2= IV_l2) , partial(i.cityid  i.prov_yr) cluster (cityid) first savefirst	estimates replay _ivreg2_ln_income_l2	mat FS= r(table)	scalar FS_b=round(FS[1,1],0.01)	scalar FS_se=round(FS[2,1],0.01)	scalar FS_p=FS[4,1]	outreg2 using regtable3.xls,stats(coef se) noaster dec(2) ctitle("Log new registrations") addstat(F for IV,  e(rkf),underid(Kleibergen-Paap rk LM), e(idstat), underid_pval, e(idp),First stage beta,FS_b,se,FS_se) nocons keep(ln_income_l2)				* Effective F stat	ivreg2 ln_saleN ln_pop   i.cityid i.prov_yr (ln_income_l2= IV_l2) ,  cluster (cityid) first savefirst	weakivtest			* COLUMN 4 lag3		qui ivreg2 ln_saleN ln_pop   i.cityid i.prov_yr (ln_income_l3= IV_l3) , partial(i.cityid  i.prov_yr) cluster (cityid) first savefirst	estimates replay _ivreg2_ln_income_l3	mat FS= r(table)	scalar FS_b=round(FS[1,1],0.01)	scalar FS_se=round(FS[2,1],0.01)	scalar FS_p=FS[4,1]	outreg2 using regtable3.xls,stats(coef se) noaster dec(2) ctitle("Log new registrations") addstat(F for IV,  e(rkf),underid(Kleibergen-Paap rk LM), e(idstat), underid_pval, e(idp),First stage beta,FS_b,se,FS_se) nocons keep(ln_income_l3)					* Effective F stat	ivreg2 ln_saleN ln_pop   i.cityid i.prov_yr (ln_income_l3= IV_l3) ,  cluster (cityid) first savefirst	weakivtest		*=======================**# TABLE 7*=======================	use income.dta,clear	merge m:1 cityid  using 2_income_q_2to5.dta* TWO GROUPS 	tab q2,gen(q2_)	foreach q of numlist 1/2{	gen i`q' = ln_income * q2_`q'	gen IV`q' = IV_lnhightechedu * q2_`q'	}		* COLUMN 1	qui ivreg2 ln_saleN ln_pop   i.cityid  i.prov_yr (ln_income i2 = IV_lnhightechedu IV2 ) , partial(i.cityid  i.prov_yr) cluster (cityid) first 	outreg2 using  regtable4.xls  ,stats(coef se) noaster dec(2) ctitle("Log new registrations") addtext(Avg quantile income in 2005 by year tend, NO) addstat(F for IV,  e(rkf),underid(Kleibergen-Paap rk LM), e(idstat), underid_pval, e(idp)) nocons keep(ln_income i2)		* COLUMN 2	qui ivreg2 ln_saleN ln_pop   i.cityid  i.prov_yr  c.avg_income_q5#i.year (ln_income i2 = IV_lnhightechedu IV2 ) , partial(i.cityid  i.prov_yr) cluster (cityid) first 		outreg2 using  regtable4.xls ,stats(coef se) noaster dec(2) ctitle("Log new registrations") addtext(Avg quantile income in 2005 by year tend, YES) addstat(F for IV,  e(rkf),underid(Kleibergen-Paap rk LM), e(idstat), underid_pval, e(idp)) nocons keep(ln_income i2)		  drop q2_1 q2_2 i1 IV1 i2 IV2* THREE GROUPS 	tab q3,gen(q3_)	foreach q of numlist 1/3{	gen i`q' = ln_income * q3_`q'	gen IV`q' = IV_lnhightechedu * q3_`q'	}		* COLUMN 3	ivreg2 ln_saleN ln_pop   i.cityid  i.prov_yr (ln_income i2 i3 = IV_lnhightechedu IV2 IV3 ) , partial(i.cityid  i.prov_yr) cluster (cityid) first 	outreg2 using  regtable4.xls  ,stats(coef se) noaster dec(2) ctitle("Log new registrations") addtext(Avg quantile income in 2005 by year tend, NO) addstat(F for IV,  e(rkf),underid(Kleibergen-Paap rk LM), e(idstat), underid_pval, e(idp)) nocons keep(ln_income i2 i3)		* COLUMN 4	ivreg2 ln_saleN ln_pop   i.cityid  i.prov_yr  c.avg_income_q5#i.year (ln_income i2 i3 = IV_lnhightechedu IV2 IV3 ) , partial(i.cityid  i.prov_yr) cluster (cityid) first 	outreg2 using  regtable4.xls ,stats(coef se) noaster dec(2) ctitle("Log new registrations") addtext(Avg quantile income in 2005 by year tend, YES) addstat(F for IV,  e(rkf),underid(Kleibergen-Paap rk LM), e(idstat), underid_pval, e(idp)) nocons keep(ln_income i2 i3 )				*=======================**# TABLE 9*=======================		use income.dta,clear			qui ivreg2 ln_saleN ln_pop   i.cityid i.prov_yr (ln_income= IV_lnhightechedu) , partial(i.cityid  i.prov_yr) cluster (cityid) first savefirst	keep prov city cityid year income Car_N   ln_income  ln_saleN	reshape wide income ln_income ln_saleN Car_N ,  i(cityid) j(year)	order prov city cityid Car_N*  ln_saleN* income* ln_income*		forvalue i = 2005/2017{	gen Car_N`i'_hat = exp((ln_income`i' - ln_income2005) * _b[ln_income] + ln_saleN2005)	}		collapse (sum) Car_N2005_hat (sum) Car_N2010_hat (sum) Car_N2017_hat	gen gr1=log(Car_N2010_hat) - log(Car_N2005_hat) //growth rate 1	gen gr2=log(Car_N2017_hat) - log(Car_N2010_hat) //growth rate 2	gen grall=log(Car_N2017_hat)-log(Car_N2005_hat)	keep gr1 gr2 grall			*---------------------------------		* Bootstrap		*--------------------------------		* First period		use income_reg_adjusted2.dta,clear 			capture program drop myboot1		program define myboot1, rclass		 preserve 			bsample,strata(cityid)			qui ivreg2 ln_saleN ln_pop   i.cityid i.prov_yr (ln_income= IV_lnhightechedu) , partial(i.cityid  i.prov_yr) cluster (cityid) first savefirst			keep prov city cityid year income Car_N   ln_income  ln_saleN			duplicates drop //since there is replacement, so might be double entry			reshape wide income ln_income ln_saleN Car_N ,  i(cityid) j(year)			order prov city cityid Car_N*  ln_saleN* income* ln_income*						forvalue i = 2005/2017{			gen Car_N`i'_hat = exp((ln_income`i' - ln_income2005) * _b[ln_income] + ln_saleN2005)			}						collapse (sum) Car_N2005_hat (sum) Car_N2010_hat (sum) Car_N2017_hat			gen gr1=log(Car_N2010_hat) - log(Car_N2005_hat) //growth rate 1			gen gr2=log(Car_N2017_hat) - log(Car_N2010_hat) //growth rate 2			gen grall=log(Car_N2017_hat)-log(Car_N2005_hat)			sum gr1						return scalar my_combination = r(mean)		 restore		end							simulate gr1=r(my_combination), reps(1000) seed(12345): myboot1				save  bs1.dta,replace				use bs1.dta,clear		sum gr1  		di r(sd) //.1644607	* Second period		use income_reg_adjusted2.dta,clear 			capture program drop myboot2		program define myboot2, rclass		 preserve 			bsample,strata(cityid)			qui ivreg2 ln_saleN ln_pop   i.cityid i.prov_yr (ln_income= IV_lnhightechedu) , partial(i.cityid  i.prov_yr) cluster (cityid) first savefirst			keep prov city cityid year income Car_N   ln_income  ln_saleN			duplicates drop //since there is replacement, so might be double entry			reshape wide income ln_income ln_saleN Car_N ,  i(cityid) j(year)			order prov city cityid Car_N*  ln_saleN* income* ln_income*						forvalue i = 2005/2017{			gen Car_N`i'_hat = exp((ln_income`i' - ln_income2005) * _b[ln_income] + ln_saleN2005)			}						collapse (sum) Car_N2005_hat (sum) Car_N2010_hat (sum) Car_N2017_hat			gen gr1=log(Car_N2010_hat) - log(Car_N2005_hat) //growth rate 1			gen gr2=log(Car_N2017_hat) - log(Car_N2010_hat) //growth rate 2			gen grall=log(Car_N2017_hat)-log(Car_N2005_hat)			sum gr2						return scalar my_combination = r(mean)		 restore		end						simulate gr2=r(my_combination), reps(1000) seed(12345): myboot2				save  bs2.dta,replace		use bs2.dta,clear		sum gr2  		di r(sd) //.21185358	* All period		use income_reg_adjusted2.dta,clear 			capture program drop mybootall		program define mybootall, rclass		 preserve 			bsample,strata(cityid)			qui ivreg2 ln_saleN ln_pop   i.cityid i.prov_yr (ln_income= IV_lnhightechedu) , partial(i.cityid  i.prov_yr) cluster (cityid) first savefirst			keep prov city cityid year income Car_N   ln_income  ln_saleN			duplicates drop //since there is replacement, so might be double entry			reshape wide income ln_income ln_saleN Car_N ,  i(cityid) j(year)			order prov city cityid Car_N*  ln_saleN* income* ln_income*						forvalue i = 2005/2017{			gen Car_N`i'_hat = exp((ln_income`i' - ln_income2005) * _b[ln_income] + ln_saleN2005)			}						collapse (sum) Car_N2005_hat (sum) Car_N2010_hat (sum) Car_N2017_hat			gen gr1=log(Car_N2010_hat) - log(Car_N2005_hat) //growth rate 1			gen gr2=log(Car_N2017_hat) - log(Car_N2010_hat) //growth rate 2			gen grall=log(Car_N2017_hat)-log(Car_N2005_hat)			sum grall						return scalar my_combination = r(mean)		 restore		end						simulate grall=r(my_combination), reps(1000) seed(12345): mybootall				save  bsall.dta,replace		use bsall.dta,clear		sum grall  		di r(sd) 			*=======================================**# APPENDIX Table A.2*=======================================		use income.dta,clear	foreach v in X_wCC X_wfe X_whp X_wGW{		gen ln_`v' = log(`v')		}	* COLUMN 1		qui ivreg2 ln_X_wCC ln_pop   i.cityid i.prov_yr (ln_income= IV_lnhightechedu) , partial(i.cityid  i.prov_yr) cluster (cityid) first savefirst	estimates replay _ivreg2_ln_income	mat FS= r(table)	scalar FS_b=round(FS[1,1],0.01)	scalar FS_se=round(FS[2,1],0.01)	scalar FS_p=FS[4,1]	outreg2 using appendix_attr.xls,stats(coef se) noaster dec(2) ctitle("Log average engine size") addstat(F statistics for IV,  e(rkf),Kleibergen-Paap rk LM, e(idstat), Under identification p value, e(idp),First stage beta,FS_b,se,FS_se) nocons keep(ln_income)	* COLUMN 2		qui ivreg2 ln_X_wfe ln_pop   i.cityid i.prov_yr (ln_income= IV_lnhightechedu) , partial(i.cityid  i.prov_yr) cluster (cityid) first savefirst	estimates replay _ivreg2_ln_income	mat FS= r(table)	scalar FS_b=round(FS[1,1],0.01)	scalar FS_se=round(FS[2,1],0.01)	scalar FS_p=FS[4,1]	outreg2 using appendix_attr.xls,stats(coef se) noaster dec(2) ctitle("Log average fuel consumption rate") addstat(F statistics for IV,  e(rkf),Kleibergen-Paap rk LM, e(idstat), Under identification p value, e(idp),First stage beta,FS_b,se,FS_se) nocons keep(ln_income)		* COLUMN 3	qui ivreg2 ln_X_whp ln_pop   i.cityid i.prov_yr (ln_income= IV_lnhightechedu) , partial(i.cityid  i.prov_yr) cluster (cityid) first savefirst	estimates replay _ivreg2_ln_income	mat FS= r(table)	scalar FS_b=round(FS[1,1],0.01)	scalar FS_se=round(FS[2,1],0.01)	scalar FS_p=FS[4,1]	outreg2 using appendix_attr.xls,stats(coef se) noaster dec(2) ctitle("Log average horsepower") addstat(F statistics for IV,  e(rkf),Kleibergen-Paap rk LM, e(idstat), Under identification p value, e(idp),First stage beta,FS_b,se,FS_se) nocons keep(ln_income)		* COLUMN 4		qui ivreg2  ln_X_wGW ln_pop  i.cityid i.prov_yr (ln_income= IV_lnhightechedu) , partial(i.cityid  i.prov_yr) cluster (cityid) first savefirst	estimates replay _ivreg2_ln_income	mat FS= r(table)	scalar FS_b=round(FS[1,1],0.01)	scalar FS_se=round(FS[2,1],0.01)	scalar FS_p=FS[4,1]	outreg2 using appendix_attr.xls,stats(coef se) noaster dec(2) ctitle("Log average gross weight") addstat(F statistics for IV,  e(rkf),Kleibergen-Paap rk LM, e(idstat), Under identification p value, e(idp),First stage beta,FS_b,se,FS_se) nocons keep(ln_income)							*=======================================**# APPENDIX TABLE A.3*=======================================		use income.dta,clear		keep year prov city cityid id_rt builtup pavedroad pop taxi bus retail o4_emp_r 	keep if year==2005	foreach v in builtup pavedroad pop taxi bus retail{	rename `v' `v'_05	}	keep cityid  *05	merge 1:m cityid using income_reg_adjusted2.dta	drop _merge	gen t=year-2004	foreach v in builtup_05 pavedroad_05 pop_05 bus_05 taxi_05 retail_05{		gen `v'_t=`v'*t		qui ivreg2 ln_saleN ln_pop  i.cityid i.prov_yr `v'_t  (ln_income= IV_lnhightechedu) , partial(i.cityid  i.prov_yr) cluster (cityid) first savefirst		estimates replay _ivreg2_ln_income		mat FS= r(table)		scalar FS_b=round(FS[1,1],0.01)		scalar FS_se=round(FS[2,1],0.01)		scalar FS_p=FS[4,1]		outreg2 using appendix_socio1.xls,stats(coef se) noaster dec(2) ctitle(`v') addstat(F for IV,  e(rkf),underid(Kleibergen-Paap rk LM), e(idstat), underid_pval, e(idp),First stage beta,FS_b,se,FS_se) nocons keep(ln_income `v'_t)	}			* Effective F stat	foreach v in builtup_05 pavedroad_05 pop_05 bus_05 taxi_05 retail_05{		gen `v'_t=`v'*t		qui ivreg2 ln_saleN ln_pop  i.cityid i.prov_yr `v'_t  (ln_income= IV_lnhightechedu) ,  cluster (cityid) first savefirst		weakivtest	}				*=======================================**# APPENDIX TABLE A.4*=======================================		use income.dta,clear		foreach v in builtup_05 pavedroad_05 pop_05 bus_05 taxi_05 retail_05{		qui ivreg2 ln_saleN ln_pop  i.cityid i.prov_yr c.`v'#i.year  (ln_income= IV_lnhightechedu) , partial(i.cityid  i.prov_yr) cluster (cityid) first savefirst		estimates replay _ivreg2_ln_income		mat FS= r(table)		scalar FS_b=round(FS[1,1],0.01)		scalar FS_se=round(FS[2,1],0.01)		scalar FS_p=FS[4,1]		outreg2 using appendix_socio2.xls,stats(coef se) noaster dec(2) ctitle(`v') addstat(F for IV,  e(rkf),underid(Kleibergen-Paap rk LM), e(idstat), underid_pval, e(idp),First stage beta,FS_b,se,FS_se) nocons keep(ln_income )	}			* Effective F stat	foreach v in builtup_05 pavedroad_05 pop_05 bus_05 taxi_05 retail_05{		qui ivreg2 ln_saleN ln_pop  i.cityid i.prov_yr c.`v'#i.year  (ln_income= IV_lnhightechedu) ,  cluster (cityid) first savefirst		weakivtest	}		*=====================================================================================================**# APPENDIX TABLE A.5*=====================================================================================================	use income.dta,clear		gen subway=0	local var subway "Presence of subway"	replace subway=1 if city=="北京市" & year>=1971	replace subway=1 if city=="天津市" & year>=1984	replace subway=1 if city=="上海市" & year>=1993	replace subway=1 if city=="广州市" & year>=1997	replace subway=1 if city=="大连市" & year>=2003	replace subway=1 if city=="深圳市" & year>=2004	replace subway=1 if city=="武汉市" & year>=2004	replace subway=1 if city=="重庆市" & year>=2005	replace subway=1 if city=="南京市" & year>=2005	replace subway=1 if city=="成都市" & year>=2010	replace subway=1 if city=="佛山市" & year>=2010	replace subway=1 if city=="沈阳市" & year>=2010	replace subway=1 if city=="长春市" & year>=2011	replace subway=1 if city=="西安市" & year>=2011	replace subway=1 if city=="杭州市" & year>=2012	replace subway=1 if city=="昆明市" & year>=2012	replace subway=1 if city=="苏州市" & year>=2012	replace subway=1 if city=="哈尔滨市" & year>=2013	replace subway=1 if city=="郑州市" & year>=2013	replace subway=1 if city=="长沙市" & year>=2014	replace subway=1 if city=="宁波市" & year>=2014	replace subway=1 if city=="无锡市" & year>=2014	replace subway=1 if city=="南昌市" & year>=2015	replace subway=1 if city=="青岛市" & year>=2015	replace subway=1 if city=="东莞市" & year>=2016	replace subway=1 if city=="福州市" & year>=2016	replace subway=1 if city=="合肥市" & year>=2016	replace subway=1 if city=="南宁市" & year>=2016	replace subway=1 if city=="贵阳市" & year>=2017	replace subway=1 if city=="石家庄市" & year>=2017	replace subway=1 if city=="厦门市" & year>=2017	* COLUMN 1 	qui ivreg2 ln_saleN ln_pop   i.cityid i.prov_yr (ln_income= IV_lnhightechedu) , partial(i.cityid  i.prov_yr) cluster (cityid) first savefirst	estimates replay _ivreg2_ln_income	mat FS= r(table)	scalar FS_b=round(FS[1,1],0.01)	scalar FS_se=round(FS[2,1],0.01)	scalar FS_p=FS[4,1]	di FS_b	di FS_se	qui outreg2 using appendix_subway.xls,stats(coef se) noaster dec(2) ctitle("Log new registrations") addtext(Socio-economic controls, NO,Excluding capitals, NO) addstat(F for IV,  e(rkf),underid(Kleibergen-Paap rk LM), e(idstat), underid_pval, e(idp),First stage beta,FS_b,se,FS_se) nocons keep(ln_income) replace 		* COLUMN 2	qui ivreg2 ln_saleN ln_pop   i.cityid i.prov_yr subway (ln_income= IV_lnhightec	hedu) , partial(i.cityid  i.prov_yr) cluster (cityid) first savefirst	estimates replay _ivreg2_ln_income	mat FS= r(table)	scalar FS_b=round(FS[1,1],0.01)	scalar FS_se=round(FS[2,1],0.01)	scalar FS_p=FS[4,1]	outreg2 using appendix_subway.xls,stats(coef se) noaster dec(2) ctitle("Log new registrations") addtext(Socio-economic controls, NO,Excluding capitals, NO) addstat(F for IV,  e(rkf),underid(Kleibergen-Paap rk LM), e(idstat), underid_pval, e(idp),First stage beta,FS_b,se,FS_se) nocons keep(ln_income subway)	* Effective F stat	ivreg2 ln_saleN ln_pop   i.cityid i.prov_yr subway (ln_income= IV_lnhightechedu) ,  cluster (cityid) first savefirst 	weakivtest	* COLUMN 3	global ln_X ln_builtup ln_pavedroad  ln_taxi ln_bus ln_retail 		qui ivreg2 ln_saleN ln_pop $ln_X  i.cityid i.prov_yr subway (ln_income= IV_lnhightechedu) , partial(i.cityid  i.prov_yr) cluster (cityid) first savefirst	estimates replay _ivreg2_ln_income	mat FS= r(table)	scalar FS_b=round(FS[1,1],0.01)	scalar FS_se=round(FS[2,1],0.01)	scalar FS_p=FS[4,1]	di FS_b	di FS_se	outreg2 using appendix_subway.xls,stats(coef se) noaster dec(2) ctitle("Log new registrations")  addtext(Socio-economic controls,YES,Excluding capitals, NO) addstat(F for IV,  e(rkf),underid(Kleibergen-Paap rk LM), e(idstat), underid_pval, e(idp),First stage beta,FS_b,se,FS_se) nocons keep(ln_income subway)				*Effective F stats	ivreg2 ln_saleN ln_pop $ln_X  i.cityid i.prov_yr (ln_income= IV_lnhightechedu) , cluster (cityid) first savefirst	weakivtest* COLUMN 4		drop if city==	"石家庄市"	drop if city==	"太原市"	drop if city==	"呼和浩特市"	drop if city==	"沈阳市"	drop if city==	"长春市"	drop if city==	"哈尔滨市"	drop if city==	"南京市"	drop if city==	"杭州市"	drop if city==	"合肥市"	drop if city==	"福州市"	drop if city==	"济南市"	drop if city==	"南昌市"	drop if city==	"郑州市"	drop if city==	"乌鲁木齐市"	drop if city==	"武汉市"	drop if city==	"长沙市"	drop if city==	"广州市"	drop if city==	"南宁市"	drop if city==	"海口市"	drop if city==	"成都市"	drop if city==	"贵阳市"	drop if city==	"昆明市"	drop if city==	"拉萨市"	drop if city==	"西安市"	drop if city==	"西宁市"	drop if city==	"兰州市"	drop if city==	"银川市"	drop if city==	"北京市"	drop if city==	"上海市"	drop if city==	"重庆市"	drop if city==	"天津市"		qui ivreg2 ln_saleN ln_pop   i.cityid i.prov_yr (ln_income= IV_lnhightechedu) , partial(i.cityid  i.prov_yr) cluster (cityid) first savefirst	estimates replay _ivreg2_ln_income	mat FS= r(table)	scalar FS_b=round(FS[1,1],0.01)	scalar FS_se=round(FS[2,1],0.01)	scalar FS_p=FS[4,1]	di FS_b	di FS_se	qui outreg2 using appendix_subway.xls,stats(coef se) noaster dec(2) ctitle("Log new registrations") addtext(Socio-economic controls, NO, Excluding capitals, YES) addstat(F for IV,  e(rkf),underid(Kleibergen-Paap rk LM), e(idstat), underid_pval, e(idp),First stage beta,FS_b,se,FS_se) nocons keep(ln_income)		